package com.ptszyxx.popose.module.main.mine;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProviders;

import com.ptszyxx.popose.BR;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.databinding.FragmentMineLookBinding;
import com.ptszyxx.popose.module.main.mine.vm.MineLookVM;
import com.ysg.base.BaseFragment;
import com.ysg.http.data.AppViewModelFactory;

import java.util.ArrayList;
import java.util.List;

public class MineLookFragment extends BaseFragment<FragmentMineLookBinding, MineLookVM> {
    private String[] mTitles;
    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_mine_look;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public MineLookVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this, factory).get(MineLookVM.class);
    }

    @Override
    public void initView() {
        super.initView();
        mTitles = getResources().getStringArray(R.array.mine_look_tab);
        binding.tabLayout.initGrid(this, binding.viewPager, mTitles, getFragment());
    }

    public List<Fragment> getFragment(){
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new MineLookTabFragment(1));
        fragments.add(new MineLookTabFragment(2));
        return fragments;
    }
}
